import type { IColumnsOption } from 'vc';
import { INDEX, COMPANY_NAME, BUSINESS_DATA, REGISTERED_CAPITAL, PROVINCE, CITY, COUNTRY, INDUSTRY_CATEGORY, INFO_SOURCE, CellRenderMap, TAG_YEAR } from '@/utils/tableColumn';

export function useTable() {
  const columns = ref<IColumnsOption[]>([
    { ...INDEX },
    { ...COMPANY_NAME },
    {
      width: 100,
      align: 'center',
      title: '披露日期',
      field: 'noticeDate',
      sortable: true
    },
    {
      ...INFO_SOURCE('tagName')
    },
    {
      width: 120,
      title: '认定级别',
      field: 'postLevel',
      align:'center',
      sortable: true,
      slots:{
        default({ row }) {
          const title = row.postLevel === '其他' ? row.greenType : '';
          return <span title={title}>{row.postLevel}</span>;
        }
      }
    },
    {
      ...TAG_YEAR,
      title: '认定年度',
      field: 'tagYear',
      sortable: true
    },
    {
      width: 220,
      title: '认定单位',
      field: 'dataSource',
      sortable: true
    },      
    { ...PROVINCE },
    { ...CITY },
    { ...COUNTRY },
    { ...INDUSTRY_CATEGORY },
    { ...BUSINESS_DATA },
    { ...REGISTERED_CAPITAL }
  ]);

  return {
    columns
  };
}
